<?php /* Smarty version 2.6.26, created on 2011-01-25 16:46:15
         compiled from admin/submodules/task.script.html */ ?>

<script type="text/javascript">
<!--<?php echo '
function showTask(id)
{
    var trs = \'\';

    $.getJSON
    (
	\'json/task.php\',
	{
	    \'action\':	\'info\',
	    \'id\':	id
	},
	function(json)
	{
	    if(json[\'code\']==200)
	    {
		if ( json[\'history\'] )
		{
		    var trs=\'\';
		    for(i=0; i<json[\'history\'].length; i++)
		    {
			trs += \'<tr class="task-comment-row ui-state-default"><td>\'+json[\'history\'][i][\'manager_name\']+\'<br/>\'+json[\'history\'][i][\'comment_date\']+\'</td><td colspan="3">\'+json[\'history\'][i][\'comment\']+\'</td></tr>\';
		    }
		}

		$(\'div#task-info\')
		    .find(\'tr\')
			.eq(0)
			    .find(\'td\')
				.eq(1)
				    .html(json[\'task\'][\'create_manager_name\'])
				    .end()
			    .end()
			    .find(\'td\')
				.eq(3)
				    .html(json[\'task\'][\'date_time\'])
				    .end()
			    .end()
			.end()
			.eq(1)
			    .find(\'td\')
				.eq(1)
				    .html(json[\'task\'][\'responsible_manager_name\'])
				    .end()
			    .end()
			    .find(\'td\')
				.eq(3)
				    .html(json[\'task\'][\'task_time\'])
				    .end()
			    .end()
			.end()
		    .end()
		    .find(\'tbody\')
			.empty()
			.append(trs)
			.end()
		    .find(\'tr.task-comment-row\')
			.hover
			(
			    function(){$(this).addClass(\'ui-state-hover\');},
			    function(){$(this).removeClass(\'ui-state-hover\');}
			)
			.end()
		    .dialog(\'option\',\'title\',\'Информация о задаче\')
		    .dialog(\'option\',\'width\',720)
		    .dialog(\'open\');
	    }
	}
    );
}

$(document).ready
(
    function()
    {
	$(\'tr.task-row\')
	    .css(\'cursor\',\'pointer\')
	    .hover
	    (
		function(){$(this).addClass(\'ui-state-hover\');},
		function(){$(this).removeClass(\'ui-state-hover\');}
	    )
	    .click(function(){showTask($(this).children().children().html());})
	    .contextMenu
	    (
		{ \'menu\':	\'task-menu\' },
		function(action,el,pos)
		{
		    function task_do(action,id,comment,manager)
		    {
			if ( $(\'#task-date-new\').val() )
			{
			    var date = $(\'#task-date-new\').val()+\' \'+$(\'#task-hour-new\').val()+\':\'+$(\'#task-minute-new\').val()+\':00\';
			}

			$.getJSON
			(
			    \'json/task.php\',
			    {
				\'action\':	action,
				\'id\':		id,
				\'comment\':	comment,
				\'manager\':	manager,
				\'date\':		date,
			    },
			    function(json){if(json[\'code\']==200){window.location.reload();}}
			);
		    }

		    switch(action)
		    {
			case	\'info\':
			    showTask($(el).children().children().html());
			    break;

			case	\'comment\':
			    $(\'div.dialog#task-comment\')
				.dialog(\'option\',\'title\',\'Оставить комментарий\')
				.dialog(\'option\',\'modal\',true)
				.dialog(\'option\',\'resizable\',false)
				.dialog
				(
				    \'option\',\'buttons\',
				    {
					\'Отмена\':	function(){$(this).dialog(\'close\');return false;},
					\'Сохранить\':	function(){task_do(\'comment\',$(el).children().children().html(),$(\'textarea#comment\').val());}
				    }
				)
				.dialog(\'open\');
			    break;

			case	\'close\':
			    if ( window.confirm(\'Оставить комментарий?\') )
			    {
				$(\'div.dialog#task-comment\')
				    .dialog(\'option\',\'title\',\'Оставить комментарий\')
				    .dialog(\'option\',\'modal\',true)
				    .dialog(\'option\',\'resizable\',false)
				    .dialog
				    (
					\'option\',\'buttons\',
					{
					    \'Отмена\':		function(){$(this).dialog(\'close\');return false;},
					    \'Закрыть задачу\':	function(){task_do(\'close\',$(el).children().children().html(),$(\'textarea#comment\').val());}
					}
				    )
				    .dialog(\'open\');
			    }
			    else
			    {
			    $(\'textarea#comment\').val(\'\');
				task_do(\'close\',$(el).children().children().html());
			    }

			    break;

			case	\'transfer\':
			    $(\'div.dialog#task-comment\')
				.find(\'p#responsible-manager\')
				    .slideDown()
				    .end()
				.dialog(\'option\',\'title\',\'Оставить комментарий\')
				.dialog(\'option\',\'modal\',true)
				.dialog(\'option\',\'resizable\',false)
				.dialog
				(
				    \'option\',\'buttons\',
				    {
				        \'Отмена\':		function(){$(this).dialog(\'close\');return false;},
				        \'Передать задачу\':	function(){task_do(\'transfer\',$(el).children().children().html(),$(\'textarea#comment\').val(),$(\'select#transfer-to\').val());}
				    }
				)
				.dialog(\'open\');
			    break;
		    }
		}
	    );
    }
);
'; ?>
-->
</script>